package com.example.demo.day.config.learn.test1.config;

import com.example.demo.day.config.learn.test1.service.HelloService;
import com.example.demo.day.config.learn.test1.service.impl.HelloServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.stereotype.Component;

@Component
//@ImportResource(locations = {"classpath:beans.xml"})
public class BeanConfiguration {

    @Value("${user.username}")
    private static String username;

    @Bean
    public HelloService helloService() {

        System.out.println("配置类@Bean给容器中添加组件了" + username + " ...");
        return new HelloServiceImpl();
    }
}
